//
//  HGLeftViewController.m
//  悦享
//
//  Created by dllo on 16/3/19.
//  Copyright © 2016年 张洪国. All rights reserved.
//

#import "HGLeftViewController.h"
#import "HGMusicViewController.h"
#import "AppDelegate.h"
#import "LeftSlideViewController.h"
#import "HGDianTaiViewController.h"
@interface HGLeftViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSArray *arrTitle;
@end

@implementation HGLeftViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithRed:0.07 green:0.2 blue:0.24 alpha:1];
    
    
    self.arrTitle = [NSArray arrayWithObjects:@"  电台 . radio station", @"  视频 . video", @"  话题 . topic ",@"  音乐 . music", @"  良品 . Good product", nil];
    
    
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 0, SREEN_WIDTH - 150, SREEN_HEIGHT - 150) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    
    
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"热门推荐"];
    NSRange strRange = {0, [str length]};
    [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleDouble] range:strRange];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake((SREEN_WIDTH - 150 - 200), 90, 200, 50)];
    [label setAttributedText:str];
    label.font = [UIFont boldSystemFontOfSize:25];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    
    [_tableView addSubview:label];
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 9;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    cell.backgroundColor = [UIColor clearColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row > 3) {
        
        
        
        cell.textLabel.text = _arrTitle[indexPath.row - 4];
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:23];
        
    }
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    AppDelegate *tempDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
    
    
    if (indexPath.row > 3) {
        NSLog(@"%ld", (long)indexPath.row);
    }
    
    if (indexPath.row == 4) {
        HGDianTaiViewController *hgDianTai = [[HGDianTaiViewController alloc] init];
        self.hidesBottomBarWhenPushed = YES;
        [tempDelegate.leftSlide closeLeftView];
        [tempDelegate.zhgNav pushViewController:hgDianTai animated:YES];
        

    }
    
    if (indexPath.row == 7) {
        HGMusicViewController *musicVC = [[HGMusicViewController alloc] init];
        
        [tempDelegate.leftSlide closeLeftView];
        
        [tempDelegate.zhgNav pushViewController:musicVC animated:YES];
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
